
server {
    {% if disable_consul_services_ie_staging is not defined %}
    listen   80;
    {% else %}
    listen   81;
    {% endif %}

    client_max_body_size 4M;
    server_name *.newsblur.com newsblur.com;
    add_header X-nginx-server nginx_none;

    set_real_ip_from  0.0.0.0/0;
    real_ip_header    X-Forwarded-For;
    real_ip_recursive on;

#    if ($host = 'newsblur.com') {
#        rewrite  ^/(.*)$  https://www.newsblur.com/$1  permanent;
#    }

    if (-f /srv/newsblur/templates/maintenance_on.html) {
        return 503;
    }
    
    location = /_nginxchk {
        return 200;
    }
    
    location /nginx_status {
        stub_status on;    # activate stub_status module
        access_log off;    
        allow 127.0.0.1;   # restrict access to local only
        deny all;
    }
    
    error_page 502 @down;
    location @down {
        root /srv/newsblur/;
        rewrite ^(.*)$ /templates/502.html break;
    }
    
    error_page 503 @maintenance;
    location @maintenance {
        if ($uri !~ ^/media/) {
            root /srv/newsblur/;
            rewrite ^(.*)$ /templates/maintenance_on.html break;
        }
        root /srv/newsblur;
    }
    
    error_page 504 @timeout;
    location @timeout {
        root /srv/newsblur/;
        rewrite ^(.*)$ /templates/502.html break;
    }

    location /media/  {
        expires max;
        keepalive_timeout 1;
        root /srv/newsblur;
    }

    location /static/  {
        gzip_static on;
        gzip on;
        gzip_comp_level 6;
        gzip_vary on;
        gzip_types text/plain text/css application/json application/x-javascript application/javascript text/xml application/xml application/rss+xml text/javascript image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype;
        expires max;
        keepalive_timeout 1;
        root /srv/newsblur;
    }

    location /favicon.ico {
        alias      /srv/newsblur/media/img/favicon_32.png;
        expires max;
    }

    location /maintenance {
        alias      /srv/newsblur/templates/maintenance_on.html;
        expires max;
        access_log on;
    }

    location ^~ /crossdomain.xml {
        expires max;
        alias /srv/newsblur/media/crossdomain.xml;
        types {
            text/x-cross-domain-policy  xml;
        }
    }

    location ^~ /robots.txt {
        expires max;
        alias /srv/newsblur/media/robots.txt;
    }

    location /munin/static/ {
        alias /etc/munin/static/;
    }

    location /munin/ {
        alias  /var/cache/munin/www/;
        # fastcgi_split_path_info ^(/munin)(.*);
        # fastcgi_param PATH_INFO $fastcgi_path_info;
        # fastcgi_pass unix:/var/run/munin/fcgi-html.sock;
        # include fastcgi_params;
    }
    
    location ^~ /cgi-bin/munin-cgi-graph/ {
        fastcgi_split_path_info ^(/cgi-bin/munin-cgi-graph)(.*);
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass unix:/var/run/munin/fcgi-graph.sock;
        include fastcgi_params;
    }

}

server {
    {% if disable_consul_services_ie_staging is not defined %}
    listen   80;
    {% else %}
    listen   81;
    {% endif %}

    server_name blog.newsblur.com blog2.newsblur.com hblog.newsblur.com;

    set_real_ip_from  0.0.0.0/0;
    real_ip_header    X-Forwarded-For;
    real_ip_recursive on;

    rewrite  ^/rss$  https://blog.newsblur.com/feed.xml  permanent;

    root /srv/newsblur/blog/_site;
}
